package imitateStudy;

import java.util.Arrays;

public class IsContinuous {

    /**
     * JZ45 扑克牌顺子
     * @param args
     */
    public static void main(String[] args) {
        IsContinuous isContinuous = new IsContinuous();
        isContinuous.IsContinuous(new int[]{0,3,1,6,4});
    }

    public boolean IsContinuous(int [] numbers) {
        Arrays.sort(numbers);
        int sum = 0;
        for (int i = 0; i < numbers.length - 1; i++){
            if (numbers[0] == 0){
                continue;
            } else if (numbers[i + 1] == numbers[i]){
                return false;
            } else {
                sum += (numbers[i + 1] - numbers[i]);
            }
        }
        return sum <= 4;
    }
}
